fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

fits_in_i64

f64.fits_in_i64

 => 
bool
[Redefinition of  float.fits_in_i64]
does this `f64` value fit into an `i64`? Used in inherited
precondition of `as_i64`.

NOTE: We cannot compare with `i64.max.as_f64` since it rounds up to 2^63,
which does not fit.

`val` is `mantissa << sh`,
where sh is the number of bits to shift the mantissa left.

sh(shift) is capped at 63, larger values do not fit.

Then we set dynamic upper bound: 2^63 for negative numbers, 2^63-1 for positive.

if sh < 0, then |val| < 2^53, which always fits.
Otherwise we check `mantissa << sh <= max_abs` via right-shift to prevent overflow.

redefines:

0.099dev (GIT hash d73ed58c41900ddb0f9db04a3da9b8f72f3699ad)
last changed: 2026-09-25